package com.agou.app.admin.business.develop.dao;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import org.hibernate.Query;

import com.agou.app.admin.business.develop.vo.DevelopVo;
import com.agou.app.admin.dbconfig.bean.TSProject;
import com.agou.core.ss.SSException;
import com.agou.core.ss.SSTrace;
import com.agou.core.util.UtString;

public class DevelopDao extends IDevelopDao {

	private static SSTrace ssTrace = SSTrace.getInstance(DevelopDao.class);

	@SuppressWarnings("unchecked")
	public List<TSProject> queryProject(String userId)
			throws SSException, SQLException, IOException {
		ssTrace.debug("queryProject", "");
		StringBuilder sbSql = new StringBuilder();
		sbSql.append("select t from TSAdminUserSecurity t ");
		sbSql.append(" where t.userId = ?");
		Query query = this.getJdbcSession().createQuery(sbSql.toString());
		query.setParameter(0, userId);
		// 对象查询条件
		return query.list();
		
	}

	@Override
	public int saveProject(TSProject vo) throws SSException, SQLException,
			IOException {
		return 0;
	}

	@Override
	public int deleProject(TSProject adminUserVo) throws SSException,
			SQLException, IOException {
		return 0;
	}

	@Override
	public TSProject queryProjectByName(String projectName) throws SSException,
			SQLException, IOException {
		return null;
	}

	@Override
	public TSProject queryProjectById(String projectName) throws SSException,
			SQLException, IOException {
		return null;
	}

	@Override
	public List<TSProject> queryProject() throws SSException, SQLException,
			IOException {
		return null;
	}

	//根据条件查询项目信息
	@SuppressWarnings("unchecked")
	public List<TSProject> queryProjectByCondition(DevelopVo vo)
			throws SSException, SQLException, IOException {
		StringBuilder sbSql = new StringBuilder();
		sbSql.append("select t from TSProject t ");
		sbSql.append(" where 1=1");
		if(UtString.isEmpty(vo.getProjectName()) == false){
			sbSql.append(" and t.projectName like :projectName ");
		}
		sbSql.append(" order by t.projectId ");
		Query query = this.getJdbcSession().createQuery(sbSql.toString());
		if(UtString.isEmpty(vo.getProjectName()) == false){
			query.setParameter("projectName", "%" + vo.getProjectName() +"%");
		}
		return query.list();
		
		
	};
}
